<?php
function accordion($contName, $pagination, $displays, $order, $offset)
{
	$checker = ifContentNameExists($contName);
	
	if ($checker == false)
	{
		$fields = array();
		$fields[0] = 'contName';
		$fields[1] = 'title';
		$fields[2] = 'contdata';
		$fields[3] = 'conttype';
		$fields[4] = 'perPage';
		$fields[5] = 'dateUpdated';
		
		$values = array();
		$values[0] = $contName;
		$values[1] = 'Accordion Component # 1';
		$values[2] = '--Please enter first entry data here--';
		$values[3] = 'blog';
		$values[4] = $pagination;
		$values[5] = sqlDateNow();
		
		$data = SQLInsert('site_content', $fields, $values);
		
		return '<div id="'.$contName.'">
			Accordion Component Created!
		</div>';
	}
	else
	{
		
		$tables = array();
		$tables[0] = 'site_content';
		
		$fields = array();
		$fields[0] = 'contentID';
		$fields[1] = 'title';
		$fields[2] = 'contdata';
		$fields[3] = 'conttype';
		$fields[4] = 'perPage';
		$fields[5] = 'dateUpdated';
		
		$whereClause = 'contName="'.$contName.'" AND conttype="blog" ORDER BY contentID '.$order;
		
		$data = SQLRecover($tables, $fields, $whereClause);
		if ($displays == 'all')
		{
			$displays = sizeOf($data['contentID']);
		}
		else
		{
			$displays = $pagination+$offset;
		}
		$display = '';
		$j=0;
		for ($i=$offset; $i<$displays; $i++)
		{
			if (!isset($data['title'][$i]))
			{
				break;
			}
			$display .= '<div id="accordionComp">
			<div class="tab" ext="'.$contName.$j.'Content">'.$data['title'][$i].'</div>
			<div id="'.$contName.$j.'Content" class="accordion">'.$data['contdata'][$i].'</div>
			</div>';
			$j++;
		}
		
		$slider = adminContent('<div id="'.$contName.'slider" class="slider">Update Last: '.dateParser(explode("-", $data['dateUpdated'][0])).popOut('javascript:void(0);', 'widget.php?page=blog&name='.$contName.'&pages='.get('page'), 'Edit', 'Edit_Content', '500', '600').'</div>', '');
		
		return $slider.'<div id="'.$contName.'" onclick="divSlider(\''.$contName.'slider\')">
			'.$display.'</div>';
	}
}
?>